package org.marsdonne.audits;

import com.fasterxml.jackson.databind.JsonNode;

public interface ChangeAuditable {
    void changed(Changed changed);

    default void changed(String domain, Changed.Method method, JsonNode before, JsonNode after) {
        this.changed(new Changed(domain, method, before, after));
    }

    default void created(String domain, JsonNode content) {
        this.changed(domain, Changed.Method.Create, null, content);
    }

    default void updated(String domain, JsonNode before, JsonNode after) {
        this.changed(domain, Changed.Method.Update, before, after);
    }

    default void deleted(String domain, JsonNode original) {
        this.changed(domain, Changed.Method.Delete, original, null);
    }
}
